package cn.edu.lcu.cs.ssm.controller;

import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import cn.edu.lcu.cs.ssm.entity.User;

/**
 * 传统的测试方式
 * @author Ling
 *
 */
class UserControllerTestClassic {
	private UserController controller ;

	@Test
	void testFindById() {
		ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//		ApplicationContext context = new AnnotationConfigApplicationContext("cn.edu.lcu.cs.ssm");
		controller = context.getBean(UserController.class);
		assertNotNull(controller);
		long id = 1L;
		User user = controller.findById(id);
		assertNotNull(user);
		assertEquals(1, user.getId());
	}

}
